//
//  MYUITabBarController.m
//  家盟商城
//
//  Created by 李志权 on 2016/10/26.
//  Copyright © 2016年 李志权. All rights reserved.
//

#import "MYUITabBarController.h"
#import "MYUINavigationController.h"
#import "massageVC.h"
#import "ecgVC.h"
#import "EntertainmentVC.h"
#import "CareVC.h"
@interface MYUITabBarController ()<UITabBarControllerDelegate>

@end

@implementation MYUITabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.delegate = self;
    MYUINavigationController *massage  = [self navigationVCInitVC:[[massageVC alloc]init] imageName:@"tab_icon5" selectedImageName:@"tab_icon1"];
    massage.tabBarItem.title =@"按摩";
    
    MYUINavigationController *ecg  = [self navigationVCInitVC:[[ecgVC alloc]init] imageName:@"tab_icon6" selectedImageName:@"tab_icon2"];
    ecg.tabBarItem.title =@"心电";
    
    MYUINavigationController *entertainment  = [self navigationVCInitVC:[[EntertainmentVC alloc]init] imageName:@"tab_icon7" selectedImageName:@"tab_icon3"];
    entertainment.tabBarItem.title =@"娱乐";
    
    MYUINavigationController *Care  = [self navigationVCInitVC:[[CareVC alloc]init] imageName:@"tab_icon8" selectedImageName:@"tab_icon4"];
    Care.tabBarItem.title =@"养生";
    self.viewControllers = @[massage,ecg,entertainment,Care];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
    
    // Dispose of any resources that can be recreated.
}
- (MYUINavigationController *)navigationVCInitVC:(UIViewController *)VC imageName:(NSString *)imageName selectedImageName:(NSString *)selectedImageName
{
    
    MYUINavigationController *NVC = [[MYUINavigationController alloc]initWithRootViewController:VC];
    NVC.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    NVC.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    NVC.tabBarItem.imageInsets = UIEdgeInsetsMake(6, 0, -6, 0);
    
    [NVC.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:GreenColor} forState:UIControlStateSelected];
    [NVC.tabBarItem setTitlePositionAdjustment:UIOffsetMake(-3, -3)];
    return NVC;
}
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
    NSLog(@"%d",tabBarController.selectedIndex);
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
